package cn.edu.xhu.library_management.area.mapper;

import cn.edu.xhu.library_management.area.entity.LmArea;
import cn.edu.xhu.library_management.area.entity.LmItemNum;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: MMJ
 * @Date: 2022 - 08 - 31
 * @Description: 物品数量Mapper类
 */
public interface ItemNumMapper {
    /**
     * 通过区域ID，获取物品数量
     * @param Area
     * @return
     */
    @Select("select *from lm_item_num where ar_id = #{areaId}")
    @Results(id = "ItemNumMap",value = {
            @Result(id = true,column = "in_id",property = "id"),
            @Result(column = "in_rows",property = "rows"),
            @Result(column = "in_columns",property = "columns"),
            @Result(column = "ar_id",property = "areaId")
    })
    public LmItemNum findItemNumByAreaId(Integer Area);

    /**
     * 通过物品数量ID，获取物品数量信息
     * @param id 物品数量ID
     * @return 物品数量信息
     */
    @Select("select *from lm_item_num where in_id = #{id}")
    @ResultMap("ItemNumMap")
    LmItemNum findItemNumById(Integer id);

    /**
     * 添加物品数量
     * @param itemNum
     * @return
     */
    @Insert("insert into lm_item_num(in_rows,in_columns,ar_id)" +
            "values (#{rows},#{columns},#{areaId})")
    public int addItemNum(LmItemNum itemNum);


    public int updateItemNum(LmItemNum itemNum);

    /**
     * 通过物品数量ID，删除物品数量
     * @param id
     * @return
     */
    @Delete("delete from lm_item_num where in_id = #{id}")
    public int deleteItemNumById(Integer id);


}
